package Tools

import (
	"strings"

	"github.com/Unknwon/goconfig"
	"iris_test/config"
)

func SubDomain(domain string) string {
	var subConfDomain, err = config.Conf["config_url"].(*goconfig.ConfigFile).GetValue("supsite", "front")
	if err != nil {
		panic("无法获取supsite.front配置!")
	}
	var sublist = [...]string{"5xy.me", subConfDomain}
	var subdomain string;
	for _, v := range sublist{
		if index := strings.Index(domain, v);index != -1 {
			subdomain = domain[0:index-1]
		}
	}
	return subdomain
}
